<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>二维码批量生成报表管理</title>
	<meta name="decorator" content="default"/>
    <link href="${ctxStatic}/css/combo.select.css?v=1" rel="stylesheet">
    <script type="application/javascript" src="${ctxStatic}/js/jquery.min.js"></script>
    <script type="application/javascript" src="${ctxStatic}/js/jquery.combo.select.js?v=1"></script>
    <style>
        .combo-select{display: inline-block;}
    </style>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#restaurantId").comboSelect();
		$(".form_datetime").datetimepicker({ 
			  language:'zh-CN',
			  todayBtn: false,
			  autoclose: true,
			  minView: "month",
			  format: 'yyyy-mm-dd'});
	});
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		layer.load(1, {
		    shade: [0.3,'#000'] //0.1透明度的白色背景
		});
		$("#searchForm").submit(); 
    	return false;
    }
	
	function findSummary()
	{
		var postForm = document.getElementById("searchForm");
		postForm.pageNo.value= 1;
		postForm.pageSize.value= 15;
		
		var startDate = postForm.createBeginTime.value;
		var endDate = postForm.createEndTime.value;
		
		var arys1= new Array();
		var arys2= new Array();
		arys1=startDate.split('-');
	    var sdate=new Date(arys1[0],parseInt(arys1[1]-1),arys1[2]);
	    
	    arys2=endDate.split('-');
	    var edate=new Date(arys2[0],parseInt(arys2[1]-1),arys2[2]);
		
	    if(sdate > edate) {
	        alert("日期开始时间大于结束时间");
	        return false;
	    }
		
		
		postForm.method="post" ;
		postForm.action = "${ctx}/basedata/qrcodeUseLog/findQrCodeSummry" ;
		postForm.submit();
		return postForm;
	}
    
    <shiro:hasPermission name="basedata:qrcodeUseLog:edit">
	function deleteById(id){
		layer.confirm('确认要删除该二维码批量生成报表吗？', {
			btn: ['确定','取消']
		}, function(){
			window.location.href='${ctx}/basedata/qrcodeUseLog/delete?id='+id;
		}, function(){
			layer.msg('删除取消', {
				time: 2000 //2s后自动关闭
				 });
		});
    }
    </shiro:hasPermission>
	</script>
</head>
<body>
	<ul class="nav nav-tabs nav-tabss">
		<li class="active"><a href="${ctx}/basedata/qrcodeUseLog/">二维码批量生成报表列表</a></li>
		<shiro:hasPermission name="basedata:qrcodeUseLog:edit"><li><a href="${ctx}/basedata/qrcodeUseLog/form">二维码批量生成报表添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="qrcodeUseLog" action="${ctx}/basedata/qrcodeUseLog/" method="post" class="breadcrumb form-search form-inline">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            <label>二维码状态：</label>
            <form:select path="qrcodeStatus" htmlEscape="false" cssClass="form-control">
            	<form:option value="" label="------请选择------"/>
	            <form:option value="0" label="未使用"/>
	            <form:option value="1" label="已绑定"/>
	            <form:option value="2" label="作废"/>
            </form:select>
            
            <label>餐厅：</label>
            <form:select path="restaurantId" htmlEscape="false" cssClass="form-control">
                <form:option value="" label="餐厅名称"/>
                <form:options items="${restaurants}" itemLabel="name" itemValue="id"/>
            </form:select>
            
            <label>生成时间：</label>
           <div class="form-group" id="data_5">
            	<div class="input-daterange input-group" id="datepicker">
            		<input type="text" readonly class="input-sm form-control form_datetime" name="createBeginTime" id="createBeginTime" value="">
                	<span class="input-group-addon">到</span>
                	<input type="text" readonly class="input-sm form-control form_datetime" name="createEndTime" id="createEndTime" value="">
            	</div>
          	</div>
          	
            
		&nbsp;<input id="btnSubmit" class="btn btn-sm btn-primary" type="submit" value="查询"/>
		&nbsp;&nbsp;&nbsp;&nbsp;<input id="create" class="btn btn-sm btn-primary" onclick="findSummary()" type="button" value="统计"/>
		  
	</form:form>
	
	<tags:message content="${message}"/>
	
	
	
	
	<c:if test="${!empty page.list}">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead><tr>
            <th>二维码ID</th>
            <th>二维码地址</th>
            <th>二维码状态</th>
            <th>绑定餐厅</th>
            <th>绑定桌号</th>
            <th>绑定时间</th>
			<shiro:hasPermission name="basedata:qrcodeUseLog:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="qrcodeUseLog">
			<tr>
                <td>${qrcodeUseLog.codeSign}</td>
                <td>${qrcodeUseLog.codeUrl}</td>
                
                <td>
	                 <c:if test="${qrcodeUseLog.qrcodeStatus == 0}">
	                 0-未使用
	                 </c:if> 
	                <c:if test="${qrcodeUseLog.qrcodeStatus == 1}">
	                 1-已绑定
	                 </c:if> 
	                 <c:if test="${qrcodeUseLog.qrcodeStatus == 2}">
	                 2-作废
	                 </c:if> 
                </td>
                <td>${qrcodeUseLog.restaurantId}</td>
                <td>${qrcodeUseLog.restaurantTableId}</td>
                <td> <fmt:formatDate value="${qrcodeUseLog.updateTime}"  dateStyle="medium" timeStyle="medium"  /></td>
				<shiro:hasPermission name="basedata:qrcodeUseLog:edit"><td>
    				<a href="${ctx}/basedata/qrcodeUseLog/form?id=${qrcodeUseLog.id}">修改</a>
                    <a href="javascript:deleteById('${qrcodeUseLog.id}')">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	</c:if>
	
	<c:if test="${!empty sumaryList}">
		<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
	            <th>餐厅ID</th>
	            <th>状态</th>
	            <th>数量</th>
			</tr>
		</thead>
		<c:forEach items="${sumaryList}" var="qrcodeUseLog">
			<tr>
				<td>${qrcodeUseLog.restaurantId}</td>
				<td>
	                 <c:if test="${qrcodeUseLog.qrcodeStatus == 0}">
	                 0-未使用
	                 </c:if> 
	                <c:if test="${qrcodeUseLog.qrcodeStatus == 1}">
	                 1-已绑定
	                 </c:if> 
	                 <c:if test="${qrcodeUseLog.qrcodeStatus == 2}">
	                 2-作废
	                 </c:if> 
                </td>
                <td>${qrcodeUseLog.codeSign}</td>
			</tr>
		</c:forEach>
		</table>
	</c:if>
	
</body>
</html>
